package com.mechat.adapter

import android.app.Activity
import android.os.Bundle
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.mechat.R
import com.mechat.ui.chat.profile.UserProfileInfoActivity
import com.mechat.util.GlideUtil

import com.custom.base.base.BaseRecyclerAdapter
import com.custom.base.util.IntentUtil
import com.github.jdsjlzx.util.SuperViewHolder
import com.mechat.bean.ModelAccountBean
import com.mechat.util.HttpRequest

class MeModelListAdapter(
    listModel: ArrayList<ModelAccountBean>,
    mActivity: Activity,
) : BaseRecyclerAdapter<ModelAccountBean>(listModel, mActivity) {
    override val layoutId: Int get() = R.layout.item_me_model_list

    override fun onBindItemHolder(
        position: Int,
        holder: SuperViewHolder,
        model: ModelAccountBean,
        payloads: List<Any>?
    ) {
        val itemAvatar = holder.getView<ImageView>(R.id.item_avatar)
        val itemName = holder.getView<TextView>(R.id.item_name)
        val bottomLine = holder.getView<View>(R.id.bottom_line)

        GlideUtil.setImageView(model.avatarUrl, itemAvatar)
        itemName.text = model.nickName
        bottomLine.visibility=if (position== itemCount-1)View.GONE else View.VISIBLE

        holder.setOnClickListener {
            HttpRequest.commonNotify("ModelListClick",model.userCode)
            val bundle = Bundle()
            bundle.putString("userCodeFriend", model.userCode)
            IntentUtil.startActivity(UserProfileInfoActivity::class.java, bundle)
        }

    }
}